package eerbaar.v2.graphics.rect;

import java.awt.Point;
import java.awt.Rectangle;

public class RectRelation {

    public static boolean isInside(Rectangle rect, Point point) {

        if (point.getX() <= rect.x || point.getX() >= rect.x + rect.width) {
            return false;
        }

        if (point.getY() <= rect.y || point.getY() >= rect.y + rect.height) {
            return false;
        }

        return true;
    }

    public static boolean isInside(Rectangle rect, Rectangle test) {

        if (isOutside(rect, RectCorners.getTopLeft(test))) {
            return false;
        }

        if (isOutside(rect, RectCorners.getTopRight(test))) {
            return false;
        }

        if (isOutside(rect, RectCorners.getBottomLeft(test))) {
            return false;
        }

        if (isOutside(rect, RectCorners.getBottomRight(test))) {
            return false;
        }

        return true;
    }

    public static boolean isOutside(Rectangle rect, Point point) {

        return !isInside(rect, point);
    }

    public static boolean isOutside(Rectangle rect, Rectangle test) {

        if (!isInside(rect, RectCorners.getTopLeft(test))) {
            return true;
        }

        if (!isInside(rect, RectCorners.getTopRight(test))) {
            return true;
        }

        if (!isInside(rect, RectCorners.getBottomLeft(test))) {
            return true;
        }

        if (!isInside(rect, RectCorners.getBottomRight(test))) {
            return true;
        }

        return false;
    }

}
